#include "SenderInputPin.h"


SenderInputPin::SenderInputPin(CBaseFilter *pFilter,
                           CCritSec *pLock,
                           CCritSec *pReceiveLock,
                           HRESULT *phr) :
    CRenderedInputPin(NAME("SenderInputPin"), 
						pFilter,
						pLock,
						phr,
						L"Input")
			,m_pReceiveLock(pReceiveLock)
{
}


SenderInputPin::~SenderInputPin(void)
{
}

HRESULT SenderInputPin::CheckMediaType(const CMediaType * mtIn)
{
    return S_OK;
}
#include <stdio.h>
//
// Receive
//
// Do something with this media sample
//
STDMETHODIMP SenderInputPin::Receive(IMediaSample *pSample)
{
	HRESULT hr ;
    CheckPointer(pSample,E_POINTER);

    CAutoLock lock(m_pReceiveLock);
    PBYTE pbData;

    REFERENCE_TIME tStart, tStop;
    pSample->GetTime(&tStart, &tStop);

    // Copy the data to the file

    hr = pSample->GetPointer(&pbData);
    if (FAILED(hr)) {
        return hr;
    }
	long n = pSample->GetActualDataLength();
	printf("GetActualDataLength:%d\n",n);
	//hr = send();//..............
    return hr;
}

//
// EndOfStream
//
STDMETHODIMP SenderInputPin::EndOfStream(void)
{
    CAutoLock lock(m_pReceiveLock);
    return CRenderedInputPin::EndOfStream();

} // EndOfStream

//
// ReceiveCanBlock
//
// We don't hold up source threads on Receive
//
STDMETHODIMP SenderInputPin::ReceiveCanBlock()
{
    return S_FALSE;
}
